package com.qyhl.webtv.module_microvideo.shortvideo.classic.detail.live;

import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.microvideo.ClassicProgramNoticeBean;
import com.qyhl.webtv.module_microvideo.common.VideoUrl;

import java.util.List;

public class ClassicLiveModel implements ClassicLiveContract.ClassicLiveModel {
    private ClassicLivePresenter mPresenter;

    ClassicLiveModel(ClassicLivePresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getList(String proId) {
        EasyHttp.get(VideoUrl.GET_CLASSIC_NOTICE_LIST)
                .params("proId", proId)
                .execute(new SimpleCallBack<List<ClassicProgramNoticeBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        if (e.getCode() == 202) {
                            mPresenter.setError("暂无任何内容！");
                        } else {
                            mPresenter.setError("请求出错，请重新获取！");
                        }
                    }

                    @Override
                    public void onSuccess(List<ClassicProgramNoticeBean> programNoticeBeans) {
                        if (programNoticeBeans != null && programNoticeBeans.size() > 0) {
                            mPresenter.setList(programNoticeBeans);
                        } else {
                            mPresenter.setError("暂无任何内容！");
                        }
                    }
                });
    }
}
